package com.zq.ssmdemo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zq.ssmdemo.mapper.DepartmentsMapper;
import com.zq.ssmdemo.pojo.Departments;
import com.zq.ssmdemo.service.IDepartmentsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 部门信息表 服务实现类
 * </p>
 *
 * @author 张乔
 * @since 2024-06-09
 */
@Service
public class DepartmentsServiceImpl implements IDepartmentsService {
@Resource
private DepartmentsMapper departmentsMapper;

    @Override
    public PageInfo<Departments> selectPage(Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        PageInfo<Departments> pageInfo = new PageInfo<>(departmentsMapper.selectList(null));

        return pageInfo;
    }

    @Override
    public void add(Departments departments) {
        departmentsMapper.insert(departments);
    }

    @Override
    public void update(Departments departments) {
        System.out.println(departments);

        departmentsMapper.updateByIdss(departments);
    }

    @Override
    public void delete(Integer id) {
        departmentsMapper.deleteByIdss(id);
    }
}
